package org.gradle;

import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;

public class MainTest {

	public static void main(String[] args) {
		try {
			URL path =new File(System.getProperty("user.dir")).toURI().toURL();
			JarLoader loader = JarLoader.getInstance(new URL[] { path });
			URL url = new File("D:\\testjar.jar").toURI().toURL();
			loader.loadJar(url);
			Class c = loader.loadClass("org.gradle.Person");
			Object person = c.newInstance();
			Method[] methods = c.getMethods();
			Method setName = c.getMethod("setName", String.class);
			Method getName = c.getMethod("getName", null);
			setName.invoke(person, "laoda");
			System.out.println(getName.invoke(person, null));
			URL[] urls = loader.getURLs();
			for (URL u : urls) {
				File f = new File(u.toURI());
				System.out.println(f.getName());
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
